import { BaseModel } from '@/common/base/base.model';
import { Column, Entity, Index } from 'typeorm';
import { BooleanNumber, EvaluationCategory, SpecificationValueType } from "common/utils/data";

@Entity('SPECIFICATION', {
  synchronize: false,
}) // 规格标准
export class SpecificationModel extends BaseModel {
  @Column({
    comment: '名称',
    type: 'varchar',
    length: 250,
  })
  @Index('SPECIFICATION.name', {
    unique: true,
  })
  name: string;

  @Column({
    comment: '描述',
    type: 'varchar',
    length: 500,
    default: '',
  })
  desc: string;

  @Column({
    comment: '排序',
    type: 'int',
    default: 1,
  })
  sort: number;

  @Column({
    comment: '类型',
    type: 'varchar',
    length: 50,
  })
  valueType: SpecificationValueType;

  @Column({
    comment: '扩展数据，如下拉枚举',
    type: 'json',
    default: {},
  })
  extra: any;

  @Column({
    comment: '是否开放给前台搜索',
    type: 'smallint',
    default: BooleanNumber.true,
  })
  openSearch: BooleanNumber;

  @Column({
    comment: '分类',
    type: 'varchar',
    length: 50,
  })
  category: EvaluationCategory;
}
